# -*- mode:makefile -*-;

include ../SETTINGS
include ../COMMON

USE_PERSDB_CONECTA = yes
DB_ACCESS_SOURCE_FILE = which_match_to_use.pl
DB_ACCESS_CONECTADB = which_match_to_use_conectadb.pl
DB_ACCESS_AMOSDB = which_match_to_use_amosdb.pl
CONECTA_LOADER = conecta_populate_db.pl

foo:
	@echo Please state a target

compile-conecta-loader:
	CIAOALIASPATH=$(CIAOALIAS) $(CIAOC) $(CONECTA_LOADER)


compile: 
# conectadb engine
	-rm -f $(DB_ACCESS_SOURCE_FILE)
#       (po must be removed to recompile appropriately)
	-rm -f *.po *.itf
	ln -s $(DB_ACCESS_CONECTADB) $(DB_ACCESS_SOURCE_FILE)
	CIAOALIASPATH=$(CIAOALIAS) $(CIAOC) match_cgi.pl
	mv -f match_cgi match_conectadb.cgi
# amosdb engine
	-rm -f $(DB_ACCESS_SOURCE_FILE)
#       (po must be removed to recompile appropriately)
	-rm -f *.po *.itf
	ln -s $(DB_ACCESS_AMOSDB) $(DB_ACCESS_SOURCE_FILE)
	CIAOALIASPATH=$(CIAOALIAS) $(CIAOC) match_cgi.pl
	mv -f match_cgi match_amosdb.cgi
	CIAOALIASPATH=$(CIAOALIAS) $(CIAOC) upload_amosdb_cgi.pl
	mv -f upload_amosdb_cgi upload_amosdb.cgi

ADMIN_CGI_DIR=$(INSTALLATION_ROOT)$(WEBDBINSTANCENAME)/admin

just-install:
# conectadb engine
	-/usr/bin/install -d \
		--mode=$(WEB_DIR_PERMISSIONS) --group=$(WWW_GROUP) \
		$(FILLIN_DIR)
	-/usr/bin/install -p \
		--mode=$(WEB_CGI_PERMISSIONS) --group=$(WWW_GROUP) \
		match_conectadb.cgi $(FILLIN_DIR)/match.cgi
# amosdb engine
	-/usr/bin/install -d \
		--mode=$(WEB_DIR_PERMISSIONS) --group=$(WWW_GROUP) \
		$(CGI_DIR)
	-/usr/bin/install -p \
		--mode=$(WEB_CGI_PERMISSIONS) --group=$(WWW_GROUP) \
		match_amosdb.cgi $(CGI_DIR)/match.cgi
	-/usr/bin/install -p \
		--mode=$(WEB_CGI_PERMISSIONS) --group=$(WWW_GROUP) \
		upload_amosdb.cgi $(ADMIN_CGI_DIR)/upload_amosdb.cgi

just-install-test:
	-mkdir --parents $(CGI_DIR_TEST)
	-chmod $(PERMISSIONS) $(CGI_DIR_TEST)
	-chgrp $(WWW_GROUP)  $(CGI_DIR_TEST)
	-cp -f match_cgi $(CGI_DIR_TEST)/match.cgi
	rsync -a Images $(CGI_DIR_TEST)

clean:
	rm -f *.po *.itf

distclean: clean
	rm -rf *.cgi
	rm -f *~

